package com.study.stream;

import com.alibaba.fastjson.JSON;
import com.study.vo.StudyMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;

/**
 * 使用默认的通信信道实现消息的接收
 */
@Slf4j
@EnableBinding(Sink.class)
public class DefaultReceiveService {

    @StreamListener(Sink.INPUT)
    public void receiveMessage(Object payLoad){

        log.info("DefaultReceiveService consume message start");

        StudyMessage _message = JSON.parseObject(
                payLoad.toString(),StudyMessage.class
        );

        log.info("DefaultSendService consume message 成功 :[{}]",
                JSON.toJSONString(_message));
    }
}
